package com.chazz.dao.impl;

import com.chazz.dao.ShoppingcarDao;
import com.chazz.entity.Shoppingcar;
import com.chazz.utils.DBUtils;

import java.sql.ResultSet;
import java.sql.SQLException;

public class ShoppingcarDaoImpl extends GenericDaoImpl<Shoppingcar,Integer> implements ShoppingcarDao {
    /**
     * 通过
     * @param uid
     * @return
     */
    @Override
    public Shoppingcar findByUid(Integer uid) {
        Shoppingcar shoppingcar = null;
        String sql = "SELECT * FROM shoppingcar WHERE uid=?";
        ResultSet rs = DBUtils.executeQuery(sql,uid);
        try{
            while(rs.next()){
                shoppingcar = reflectUtils.newInstance(Shoppingcar.class,rs);
            }
        }catch (SQLException throwables){
            throwables.printStackTrace();
        }finally {
            DBUtils.close();
        }
        return shoppingcar;
    }
}
